<%@ page import="dao.ProductDao" %>
<%@ page import="domain.Product" %><%--
  Created by IntelliJ IDEA.
  User: ThinkPad
  Date: 2021/12/25
  Time: 11:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false"%>
<html>
<head>
    <title>后台-商品修改页面</title>
</head>
<body>
<%@include file="headForRoot.jsp"%>
<%
    String modifyString = request.getParameter("modify");
    if (modifyString ==null){
%>
<script>
    alert("您没有指定要修改的产品。是怎么导航到此页面的？");
    window.location="manage.jsp";
</script>
<%
}else{
    ProductDao dao = new ProductDao();
    try {
        int modify = Integer.parseInt(modifyString);
        Product product = dao.search(modify);
        if (product!=null){
%>
<div style="text-align: center">
    <br /><div style="color: green">温馨提示：如果某项属性无需修改，允许直接留空</div><br /><br />
    <form name="modify" action="${pageContext.request.contextPath}/modifyMessage.jsp?modify=<%=product.getId()%>" method="post">
        <table style="margin-left: 25%;width: 50%;text-align: center">
            <tr>
                <td style="border: 1px olivedrab;width: 100px"><b>商品属性</b></td>
                <td style="border: 1px olivedrab;width: 300px"><b>原值</b></td>
                <td style="border: 1px olivedrab"><b>修改值</b></td>
            </tr>
            <tr>
                <td>名称</td>
                <td><%=product.getName()%></td>
                <td><label><input type="text" name="pname"></label></td>
            </tr>
            <tr>
                <td>库存</td>
                <td><%=product.getCount()%></td>
                <td><label><input type="number" max="1000" min="0" name="quantity"></label></td>
            </tr>
            <tr>
                <td>价格</td>
                <td><%=product.getPrice()%></td>
                <td><label><input type="text" name="price"></label></td>
            </tr>
            <tr>
                <td>描述</td>
                <td><%=product.getDescription()%></td>
                <td><label><input type="text" name="desc"></label></td>
            </tr>
            <tr>
                <td>图片</td>
                <td><%=product.getImg()%></td>
                <td>*暂不支持*</td>
            </tr>
        </table>
        <br />
        <input type="submit" value="提交">
    </form>
</div>
<%
            }
        }catch (NumberFormatException e){
            e.printStackTrace();
        }
    }
%>
<%@include file="tail.jsp"%>
</body>
</html>
